/*
  in_unreal.dll - Winamp Plugin 
  
  Andrzej Oczkowicz [andREV] 
  andrew_lz@poczta.fm
  
  About Box dialog code  
  
*/


#include <windows.h>


extern HINSTANCE hInstance;
extern const buff_size;

HWND lbl_mail, ico_amp;

BOOL AEnumChildProc(HWND hwnd, LPARAM lParam)
{
  int i = GetWindowLong(hwnd, GWL_ID);
  switch (i)
  {
   case 130: lbl_mail = hwnd;
     break;      
   case 140: ico_amp = hwnd;
     break;                  
  }  
  return TRUE;
}


LRESULT about_dlg(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{	
	switch(msg)
	{	
		case WM_INITDIALOG:{
         EnumChildWindows(hwnd, (ENUMWINDOWSPROC)AEnumChildProc, 0);
        // m(GetCommandLine());
         char app_n[buff_size];
         GetModuleFileName(0, app_n, buff_size);        
         /*
         char *app = (char *)getString(GetCommandLine());
         char *app_n = app;          
         if (app[strlen(app) - 1] == ' ') 
           app_n[strlen(app_n) - 1] = 0;
         if (app_n[0] == '"')
           app_n++;
         if (app_n[strlen(app_n) - 1] == '"')
           app_n[strlen(app_n) - 1] = 0;               
         m(app_n);      
         */     
         HICON ico = ExtractIcon(hInstance, app_n, 0);
         if (ico) m("ico ok");
         SendMessage(ico_amp, STM_SETIMAGE, IMAGE_ICON, (LPARAM)ico);
      //   delString(&app);
			break;
     }			
  	case WM_COMMAND:
  	   switch(wParam)
       {  
         case 111:
           SendMessage(hwnd, WM_DESTROY, 0, 0);
           break; 
           
         case 130:  
           break;                                                   
  	   }    
			break;
    case WM_SYSCOMMAND :
            if (wParam == SC_CLOSE){ 
              SendMessage(hwnd, WM_DESTROY, 0, 0);	
            return 1;  
           }     
      break;    
         
		case WM_CLOSE:
		      SendMessage(hwnd, WM_DESTROY, 0, 0);
		      return 1;
			break;
           		
		case WM_DESTROY:
		      EndDialog(hwnd, 0);
		      return 1;
			break;
	}
	return 0;
}


void show_about(HWND parent)
{      
  DialogBoxParam(hInstance, MAKEINTRESOURCE(150), parent, (DLGPROC)about_dlg, 0);           
}

